home *** CD-ROM | disk | FTP | other *** search
Text File | 1990-04-27 | 1.8 KB | 45 lines | [TEXT/GEOL] |
- Item forwarded by A33 to A34
-
- Item 6441297 25-April-90 08:11PDT
-
- From: ALGER Alger, Jeff,VCA
-
- To: D4281 IDS, Larry Forbord,AST
-
- cc: MACAPP.TECH$ MacApp Technical
-
- Sub: Re: TAssociation Question
-
- Larry,
-
- The problem with a many-to-many TAssociation is not storing the pairs, it is
- retrieval. There are no methods provided to iterate over the values associated
- with a given key: there is a built-in presumption that the key uniquely
- determines a single value. For what it is worth, I will share a solution
- derived for a prior project.
-
- A "multiset" or "bag" in set theory is a set whose elements are not necessarily
- distinct. In my TMultiSet, two objects might be different objects, yet be
- considered "equal" in the set based on some comparison function. Comparing the
- key parts of key-value pairs would qualify.
-
- The principal method for access was EachMatch method, which iterated over all
- matching elements of the set given a "template" object against which to
- compare. Also provided were iterators in first-next and last-previous fashion
- (using greatest lower bound and least upper bound as starting points,
- respectively) and these combined to provide range searching. These were also
- used to implement deletion: in your situation, deletion of a key should delete
- all values associated with it.
-
- You could probably hack up TAssociation by adding the EachMatch method, but
- probably would find it easier all around to just implement a new class.
- Adapting the binary search algorithm for a multiset is a non-trivial problem.
- Better yet, since the code I implemented is owned by Apple, maybe they can be
- convinced to release it (are you listening Steve?)
-
- Regards,
- Jeff Alger
- Exis
- A Technology Firm of KPMG Peat Marwick
-
-